/**
 * Simple script experiment to create an top comments tooltip by Astin
 * Visit: http://astinquery.blogspot.com
 * Update: 27 juli 2014
 */
function topkomentar(json) {
    var skeleton = "";
    skeleton = '<ul class="comment-x-post">';
    for (var i = 0; i < json.count; i++) {
        var d = json.value.items[i];
        var co = cm_top_comments,
            href = d.link,
            newsize = "/s" + co.size,
            nama = d.author.name,
            itez = d.author['gd:image'].src.replace(/\/s(512|220)/g, "" + newsize + ""),
            total = d.title.replace(/([^0-9])/g, "");
        if (json.value.items[i].link == "") {
            skeleton += "<li class='items-cmx'>" + json.value.items[i].title + "</li>";
        } else {
            skeleton += "<li class='items-cmx'><img class='author-photo' height='" + co.size + "' width='" + co.size + "' src='" + itez + "'/><div class='tolltip item1'><span class='tol_wrap'><span class='author_big_photo'><img height='" + co.size + "' width='" + co.size + "' src='" + itez + "'/></span><span class='small-tol'><span class='title_author32'>" + nama.substring(0, 14) + "</span><span class='span_count'>" + total + "</span><span class='coments48text'>Comment this post</span></span></span></div></li>";
            document.getElementById(co.idName).innerHTML = skeleton;
        }
    }
    skeleton += '</ul>';
    document.getElementById(co.idName).innerHTML = skeleton;
}

(function () {
    var head = document.getElementsByTagName('head')[0],
        script = document.createElement('script'),
        co = cm_top_comments;
    script.type = "text/javascript";
    script.id = "feed-script";
    script.src = "http://pipes.yahoo.com/pipes/pipe.run?YourBlogUrl=" + co.home_page + "&ExcludedNick1=Zhinto&ShowHowMany=" + co.max_result + "&_callback=topkomentar&_id=23022d7836bf2dd3c10a329feb9be26a&_render=json";
    head.appendChild(script);
})();